package team.seekers.hula.user.userHula.controller;


import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.user.userHula.entity.dto.UserHulaQueryDTO;
import team.seekers.hula.user.userHula.entity.vo.UserHulaInfoVO;
import team.seekers.hula.user.userHula.entity.vo.UserHulaListVO;
import team.seekers.hula.user.userHula.service.UserHulaService;

import javax.annotation.Resource;

/**
 * @author hbc
 * @since 2023-01-30
 */
@Controller
@ApiResponseBody
@RequestMapping("/user/hula")
public class UserHulaController {

    @Resource
    private UserHulaService userHulaService;

    @GetMapping("/info")
    public UserHulaInfoVO get(@RequestParam(required = false) String id) {
        if(StringUtils.isNotBlank(id)){
            return userHulaService.getHulaInfoVO(id);
        }else {
            return userHulaService.getHulaInfoVO(MindUtils.getUserId());
        }
    }

    @GetMapping("/page")
    public PageResult<UserHulaListVO> page(UserHulaQueryDTO queryDTO) {
        return userHulaService.pageOrderTime(queryDTO);
    }

}

